<html><head>
   <title>Using matplotlib with PyScripter</title>
   <meta name="generator"  content="HelpMaker.net">
   <meta name="keywords"  content="matplotlib,Python enginesRunning scripts"></head>
<body bgcolor="#FFFCEA">
<table width="100%"  border="0"  cellspacing="0"  cellpadding="2"  bgcolor="#C0C0C0">
  <tr>
    <td align="left">
      <div align="left"><font face="Arial"  color="#010101"  size="4"><span style=" font-size:14pt; font-family:Arial; color:#010101">Using matplotlib with PyScripter</span></font></div>

    </td>
    <td align="right">
      <font face="Arial"  size="2">
        <a href="postmortemanalysis.htm">Previous</a>&nbsp;<a href="pyscripter.htm">Top</a>&nbsp;<a href="debuggingdjangoapplications.htm">Next</a>
      </font>
    </td>
  </tr></table>
<hr><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">With the new </span></font><a href="remotepythonengines.htm"><font face="Arial"  color="#0000ff"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#0000ff"><u>Remote Python Engines</u></span></font></a><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101"> you can now run </span></font><a href="http://matplotlib.sourceforge.net/"><font face="Arial"  color="#0000ff"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#0000ff"><u>matplotlib</u></span></font></a><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101"> in interactive mode.&nbsp; Here is 
how:</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101"><br></span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">1)&nbsp; Choose the right Python engine (Run, Python Engine menu option) for the backend of your 
choice&nbsp; e.g.&nbsp; Remote engine Tk for the &quot;TkAgg&quot; backend or Remote Engine wx for the &quot;WX&quot; and 
&quot;WxAggg&quot; backends.</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101"><br></span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">2) Assuming that you have selected the Remote Engine wx, issue the following commands in the 
interpreter:</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101"><br></span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">&gt;&gt;&gt; import matplotlib</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">&gt;&gt;&gt; matplotlib.interactive(True)</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">&gt;&gt;&gt; matplotlib.use(&quot;WXAgg&quot;)</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">&gt;&gt;&gt; from matplotlib.pylab import *</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">&gt;&gt;&gt; plot([1,2,3])</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">&gt;&gt;&gt; xlabel('time (s)')</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101"><br></span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">You can set the backend and interactive mode in the matplotlibrc file. If this is done, the following 
is sufficient for the above example:</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101"><br></span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">&gt;&gt;&gt; from pylab import *</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">&gt;&gt;&gt; plot([1,2,3])</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">&gt;&gt;&gt; xlabel('time (s)')</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101"><br></span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">3)&nbsp; Issue more pylab commands, or close the pylab window and call plot again for a new plot, etc. </span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101"><br></span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101"><br></span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101"><b>Sample script by heylam</b></span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">#Tested on: PyScripter 1.9.9.2, Matplotlib 0.91.2</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">#Assumed setup:</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">#In site-packages\matplotlib\mpl-data\matplotlibrc set backend to WXAgg.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">def demoplot():</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; '''This represents your work'''</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; close('all') #closes figures</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; t = c_[0:1:20j]</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; s = cos(2*pi*t)</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; for ampl in c_[0.1:1:10j]:</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; plot(t, ampl*s, 'o-', lw=2)</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; xlabel('time (s)')</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; ylabel('voltage (mV)')</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; title('demo', color='b')</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; grid(True)</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; draw() #update figure if already shown</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">#Select a demonstration:</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">if 0:&nbsp; #Normal session</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; #Starts non-interactive.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; #Figures have toolbar for zooming and panning.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; #Disadvantage: You can't re-run your script with PyScripter Remote</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; # engine without first reinitializing the Remote interpreter.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; #Best use Remote(Wx) engine. This also allows interactive mode using</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; # ion() and ioff(). For disadvantages: see the PyScripter help file.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; #from numpy import *</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; #from scipy import *&nbsp; #includes numpy</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; from pylab import *&nbsp;&nbsp; #includes scipy</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; demoplot()</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; show() #Open the figure, let figure GUI take over.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #This should be last line of script.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #You can also type this at command line after the script exits.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; if 0:</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ion() #turns interactive mode on&nbsp;&nbsp; (needs Remote(Wx) engine!)</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ylabel('interactive modification')</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; plot( rand(200), rand(200), 'go' )</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ioff() #turns interactive mode off</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">elif 0:&nbsp; #Same but use WX instead</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; try:</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type(matplotlib)</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; except NameError:</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import matplotlib</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; matplotlib.use('WX')</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from matplotlib.pylab import *</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; demoplot()</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; show() #Open the figure, let figure GUI take over.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #This should be last line of script.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #You can also type this at command line after the script exits.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">elif 0:&nbsp; #Same but start as interactive session, needs Remote(Wx)engine.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; try:</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type(matplotlib)</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; except NameError:</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import matplotlib</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; matplotlib.interactive(True)</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from matplotlib.pylab import *</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; demoplot()</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; show() #Open the figure, let figure GUI take over.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #This should be last line of script.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #You can also type this at command line after the script exits.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">elif 0:#pdf output, allows use of Remote engine without re-initialization.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; #Disadvantage: no figure toolbar.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; #WARNING: close the file in acrobat reader before the next run.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; #(Maybe other pdf viewers don't block file overwrite?)</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; try:</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type(matplotlib)</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; except NameError:</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import matplotlib</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; matplotlib.use('PDF')</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from pylab import *</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; demoplot()</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; filename='demo_plot'</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; savefig(filename)</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; #view the file:</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; import win32api</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; win32api.ShellExecute(0, &quot;open&quot;, filename+'.pdf', None, &quot;&quot;, 1)</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">elif 1:#png output, allows use of Remote engine without re-initialization.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; #Disadvantage: no figure toolbar.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; #Tip: make Irfanview your standard viewer.</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; from pylab import *</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101"><br></span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; demoplot()</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; filename='demo_plot'</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; savefig(filename)</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; #view the file:</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; import win32api</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">&nbsp;&nbsp;&nbsp; win32api.ShellExecute(0, &quot;open&quot;, filename+'.png', None, &quot;&quot;, 1)</span></font></div>

</body></html>
